package com.shensi.api.pay.client;

import com.shensi.api.pay.param.request.UpdateIntegralRequest;
import com.shensi.api.pay.pojo.PayOrder;
import com.shensi.api.pay.pojo.dto.CarWashPaymentDto;
import com.shensi.api.pay.pojo.dto.NewCarWashPaymetDto;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.api.pay.param.ResultData;
import com.shensi.common.core.domain.model.LoginBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.SneakyThrows;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.Map;

/**
 * <Title> PosMachineController </Title>
 * <Description> POS机端模块功能 </Description>
 *
 * @Date 2021年3月17日
 */

@Api(tags = "POS端接口")
@FeignClient(name = CloudConstant.PAY_SERVER)
public interface PosMachineClient {


    /*
     * POS 根据会员码或者手机号 查询会员信息
     * @param stationId
     * @param memberCode
     * @param mobilePhone
     * @return
     */
    @RequestMapping(value = "/selectMemberToPos", method = RequestMethod.GET)
    @ApiOperation(value = "POS 根据会员码或者手机号 查询会员信息", httpMethod = "GET", notes = "POS 根据会员码或者手机号 查询会员信息")
    @ResponseBody
    public String selectMemberToPos(@RequestParam("stationId") Integer stationId,@RequestParam(value = "keywords",required = false) String keywords);

    /*
     * POS 扫码核销用户积分
     * @param memberCode
     * @param integral
     * @param stationId
     * @return
     */
    @RequestMapping(value = "/writeOffUserIntegral", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "扫码核销用户积分", httpMethod = "GET", notes = "扫码核销用户积分")
    @Transactional
    public String writeOffUserIntegral(@ApiParam(value = "会员码", required = true) @RequestParam("memberCode") String memberCode,
                                       @ApiParam(value = "积分", required = true) @RequestParam("integral") Integer integral,
                                       @ApiParam(value = "核销人员ID（POS机登陆人员）", required = true) @RequestParam("userId") Integer userId,
                                       @ApiParam(value = "油站ID", required = true) @RequestParam("stationId") Integer stationId);

    //POS机端用户登录
    @RequestMapping(value = "/loginPosMachine", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "pos登录", httpMethod = "POST", notes = "pos登录：3des加密密码：LAnZ8RRSkIY0EGVYheu2IjEk；参数信息：userName(用户名); password：密码（加密后的字符串）；deviceNo（设备唯一编码）")
    public String loginPosMachine(@RequestBody LoginBody loginBody);


    //根据POS机tusn获取该油站油枪绑定的POS机信息
    @RequestMapping(value = "/getStationDeviceManagerBytusn", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "POS机根据tusn获取该油站油枪绑定的POS机信息", httpMethod = "GET", notes = "获取该油站油枪绑定的POS机信息")
    public String getStationDeviceManagerBytusn(@ApiParam(value = "POS码", required = true) @RequestParam("tusn") String tusn);

    //POS机根据随机码查询订单信息
    @RequestMapping(value = "/selectPosPayOrderInfoByOrderRandomId", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "POS机根据随机码查询订单信息", httpMethod = "GET", notes = "POS机根据随机码查询订单信息")
    public String selectPosPayOrderInfoByOrderRandomId(@ApiParam(value = "POS码", required = true) @RequestParam("orderRandomId") String orderRandomId);

    // 获取订单的支付方式列表
    @GetMapping(value = "/selectPayTypeList")
    @ResponseBody
    @ApiOperation(value = "获取订单的支付方式列表", httpMethod = "GET")
    public String selectPayTypeList();

    /*
     * 查询订单列表
     * @param stationId
     * @param userName
     * @return
     */
    @RequestMapping(value = "/selectPosPayOrdersList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查询订单列表", httpMethod = "POST", notes = "查询订单列表所用到参数：stationId(油站ID);pageNum（页码）；pageSize（页面大小）； beginTime（开始时间）；endTime（结束时间）；支付方式（非必传）")
    public String selectPosPayOrdersList(@RequestBody PayOrder request);

    /*
     * 查询小程序现金支付轮询订单列表
     * @param stationId
     * @param userName
     * @return
     */
    @RequestMapping(value = "/posSelectAppCashPayOrdersList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查询小程序现金支付轮询订单列表", httpMethod = "POST")
    public String posSelectAppCashPayOrdersList(@RequestBody PayOrder request);


    /**
     * 导入
     */
    @PostMapping("/upPostErrorLog")
    @ResponseBody
    public String importCardExcelFile(@RequestParam("file") MultipartFile file);


    /*
     * oss sts服务器
     * @param payInfoRequest
     * @return
     */
    @ApiOperation(value = "消费支付拉起第三方支付", httpMethod = "POST", notes = "消费支付拉起第三方支付")
    @PostMapping(value = "/getOssToken")
    public String getOssToken();

    @RequestMapping(value = "/updateIntegral", method = RequestMethod.POST)
    @ApiOperation(value = "积分调整", httpMethod = "POST", notes = "POS机给会员积分调整")
    @ResponseBody
    public String updateIntegral(@Valid @RequestBody UpdateIntegralRequest integralRequest);

//    @SneakyThrows
    @RequestMapping(value = "/carWashPayment", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "洗车券核销", httpMethod = "POST", notes = "pos机扫码核销洗车券")
    public ResultData<?> carWashPayment(@Valid @RequestBody CarWashPaymentDto cw);

    @ApiOperation(value = "查询油站支付渠道", notes = "data.channel 支付渠道号，1-随行付，5-云化，默认找后台配置的，找不到找随行付的，都没有会报错")
    @GetMapping("getStationPayWay")
    @ResponseBody
    public ResultData<Map<String, String>> getStationPayWay(@RequestParam("stationId") Integer stationId);

    @RequestMapping(value = "/newCarWashPayment", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "核销", httpMethod = "POST", notes = "pos机扫码核销")
    public ResultData<?> newCarWashPayment(@Valid @RequestBody NewCarWashPaymetDto cw);
}
